Do...While

General Control Statement

Syntax samples

DO <statement block> WHILE <Boolean expression>


DO INC Var1 WHILE Array1[Var1] <> 10

DO
BEGIN
INC Var2, 5
WAIT 5 sec
END
WHILE FreeCap(Loc1) > 5

Description

Repeats a statement or statement block continuously while a condition remains true. DO...WHILE is an exit-condition loop, meaning that the loop will always execute at least once. Use DO...WHILE for processes that must be executed one time and possibly more.

Please note

Use caution when using a DO...WHILE with a system function (e.g., FREECAP()) to ensure that the system does not enter an infinite loop. For example, eliminating the "WAIT 5 sec" in the syntax sample will cause the system to enter an infinite loop because there is no time delay within the loop.

Valid In

Any logic.

Components

<statement block>

The statement or block of statements to execute.

<Boolean expression>

As long as this expression is TRUE, the loop will continue. This expression is evaluated for each iteration of the loop.

Example

The logic below orders a minimum of ten cases to location Receiving every time it is encountered. As long as the location has a capacity greater than ten, it will send additional sets of ten entities to the location.

DO
ORDER 10 Cases to Receiving
WHILE FREECAP(Receiving) > 10

See Also

BEGIN, END, DO...UNTIL, and WHILE...DO.